package com.ruoyi.backend.controller.app;

import com.ruoyi.backend.domain.Carousel;
import com.ruoyi.backend.service.ICarouselService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统轮播图Controller
 * 
 * @author wjr
 * @date 2025-09-25
 */
@RestController
@RequestMapping("/app/backend/t_carousel")
@Api(tags = "app-系统轮播图")
public class AppCarouselController extends BaseController
{
    @Autowired
    private ICarouselService carouselService;

    /**
     * 查询系统轮播图列表
     */
//    @PreAuthorize("@ss.hasPermi('backend:t_carousel:list')")
    @GetMapping("/list")
    @ApiOperation("查询系统轮播通告列表")
    public TableDataInfo list(Carousel carousel)
    {
        startPage();
        List<Carousel> list = carouselService.selectCarouselList(carousel);
        return getDataTable(list);
    }

    /**
     * 获取系统轮播图详细信息
     */
//    @PreAuthorize("@ss.hasPermi('backend:t_carousel:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取系统轮播图详细信息")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(carouselService.selectCarouselById(id));
    }

    /**
     * 新增系统轮播图
     */
//    @PreAuthorize("@ss.hasPermi('backend:t_carousel:add')")
    @Log(title = "系统轮播图", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增系统轮播图")
    public AjaxResult add(@RequestBody Carousel carousel)
    {
        return toAjax(carouselService.insertCarousel(carousel));
    }

    /**
     * 修改系统轮播图
     */
//    @PreAuthorize("@ss.hasPermi('backend:t_carousel:edit')")
    @Log(title = "系统轮播图", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改系统轮播图")
    public AjaxResult edit(@RequestBody Carousel carousel)
    {
        return toAjax(carouselService.updateCarousel(carousel));
    }

    /**
     * 删除系统轮播图
     */
//    @PreAuthorize("@ss.hasPermi('backend:t_carousel:remove')")
    @Log(title = "系统轮播图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除系统轮播图")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(carouselService.deleteCarouselByIds(ids));
    }

    /**
     * 导出系统轮播图列表
     */
    /*@PreAuthorize("@ss.hasPermi('backend:t_carousel:export')")
    @Log(title = "系统轮播图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Carousel carousel)
    {
        List<Carousel> list = carouselService.selectCarouselList(carousel);
        ExcelUtil<Carousel> util = new ExcelUtil<Carousel>(Carousel.class);
        util.exportExcel(response, list, "系统轮播图数据");
    }*/

}
